//对称二叉树
class Solution2 {
    class TreeNode{
        public int val;
        public TreeNode left;
        public TreeNode right;

        public TreeNode(int val) {
            this.val = val;
        }
    }
    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return  true;
        }
        return isSymmetric1(root.left,root.right);
    }
    public  boolean isSymmetric1(TreeNode leftTree,
                                 TreeNode rightTree){
        if(leftTree==null&&rightTree!=null
        ||rightTree==null&&leftTree!=null){
            return  false;
        }
        if(leftTree==null&&rightTree==null){
            return  true;
        }
        if(leftTree.val==rightTree.val){
            return true;
        }
        return isSymmetric1(leftTree.left,rightTree.right)
                &&isSymmetric1(leftTree.right,rightTree.left);
    }
}